package cn.edu.zafu.bigdata.lhff;

abstract class Shape {
    public abstract double area();
    public abstract double perimeter();
    public final void display() {
        System.out.println("Shape Type: " + this.getClass().getSimpleName());
        System.out.println("Area: " + area());
        System.out.println("Perimeter: " + perimeter());
    }
}

class Circle extends Shape {
    private final double radius;

    public Circle(double radius) {
        this.radius = radius;
    }

    public double area() {
        return Math.PI * radius * radius;
    }

    public double perimeter() {
        return 2 * Math.PI * radius;
    }
}

class Rectangle extends Shape {
    private final double length;
    private final double width;

    public Rectangle(double length, double width) {
        this.length = length;
        this.width = width;
    }

    public double area() {
        return length * width;
    }

    public double perimeter() {
        return 2 * (length + width);
    }
}

public class ShapeDemo {
    public static void main(String[] args) {
        Shape circle = new Circle(5);
        Shape rectangle = new Rectangle(4, 6);

        circle.display();
        System.out.println();
        rectangle.display();

        final int constant = 10;
        System.out.println("Final variable value: " + constant);

        class BaseClass {
            public final void finalMethod() {
                System.out.println("This is a final method.");
            }
        }

        BaseClass base = new BaseClass();
        base.finalMethod();
    }
}
